package org.oslims.client.view.impl;

import org.oslims.client.uicomponents.editbox.EditParameterBox;
import org.oslims.client.view.ParameterEditorView;
import org.oslims.domain.Parameter;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ParameterEditorViewImpl extends BaseViewImpl implements ParameterEditorView {

	final Button addParameterButton = new Button("Add Parameter");

	Integer defaultPageSize = 15;

	final CellTable<Parameter> parameterTable = new CellTable<Parameter>(defaultPageSize);
	final SimplePager<Parameter> pager = new SimplePager<Parameter>(parameterTable);

	EditParameterBox editParameterBox = new EditParameterBox();

	public ParameterEditorViewImpl() {

		DockLayoutPanel content = new DockLayoutPanel(Unit.PCT);
		content.setStyleName("mainContent");

		VerticalPanel headerPanel = new VerticalPanel();

		Label header = new Label("Parameter Management");
		header.setStyleName("viewHeader");

		headerPanel.add(header);
		content.addNorth(headerPanel, 5);

		VerticalPanel footerPanel = new VerticalPanel();
		footerPanel.add(pager);
		footerPanel.add(addParameterButton);
		content.addSouth(footerPanel, 10);

		ScrollPanel tablePanel = new ScrollPanel();
		tablePanel.add(parameterTable);

		content.add(tablePanel);

		initWidget(content);
	}

	@Override
	public HasClickHandlers getAddParameterButton() {
		return addParameterButton;
	}

	@Override
	public CellTable<Parameter> getTable() {
		return parameterTable;
	}

	@Override
	public EditParameterBox getEditParameterBox() {
		return editParameterBox;
	}

	@Override
	public Integer getDefaultPageSize() {
		return defaultPageSize;
	}

	@Override
	public SimplePager<Parameter> getPager() {
		return pager;
	}

}
